<template>
  <el-form label-width="100px">
    <CommonProps />
    <el-form-item label="默认值">
      <el-input v-model="fs.getProps().defaultVal" placeholder="请输入默认值" />
    </el-form-item>
    <el-form-item label="最多输入">
      <el-input v-model="fs.getProps().length" placeholder="请输入长度" oninput="value=value.replace(/[^\d]/g,'')">
        <template #append>个字符</template>
      </el-input>
    </el-form-item>
    <el-form-item label="前缀">
      <el-input v-model="fs.getProps().prefix" placeholder="请输入前缀" />
    </el-form-item>
    <el-form-item label="后缀">
      <el-input v-model="fs.getProps().suffix" placeholder="请输入后缀" />
    </el-form-item>
    <el-form-item label="前缀">
      <el-input v-model="fs.getProps().prefixIcon" placeholder="请选择前图标" clearable>
        <template #append>
          <Search class="search-icon" @click="dialogIconVisible.prefix = true" />
        </template>
      </el-input>
    </el-form-item>
    <el-form-item label="后缀">
      <el-input v-model="fs.getProps().suffixIcon" placeholder="请选择后图标" clearable>
        <template #append>
          <Search class="search-icon" @click="dialogIconVisible.suffix = true" />
        </template>
      </el-input>
    </el-form-item>
    <CommonPropsTwo />
    <DialogIcon v-model:visible="dialogIconVisible.prefix" @ok="onSelectedPrefixIcon" />
    <DialogIcon v-model:visible="dialogIconVisible.suffix" @ok="onSelectedSuffixIcon" />
  </el-form>
</template>

<script setup lang="ts">
import { reactive } from 'vue'
import CommonProps from '../../common-props/Props.vue'
import CommonPropsTwo from '../../common-props/PropsTwo.vue'
import { ElForm, ElFormItem, ElInput } from 'element-plus'
import { Search } from '@element-plus/icons-vue'
import { useFlowStore } from '@/stores/flow'
import DialogIcon from '../../supports/DialogIcon.vue'

const fs = useFlowStore()

const dialogIconVisible = reactive({ prefix: false, suffix: false })

const onSelectedPrefixIcon = (icon: any) => {
  fs.getProps().prefixIcon = icon.name
}
const onSelectedSuffixIcon = (icon: any) => {
  fs.getProps().suffixIcon = icon.name
}
</script>

<style lang="scss" scoped>
.search-icon {
  width: 1em;
  height: 1em;
  cursor: pointer;
}
</style>
